<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 前端 主动发送JS请求，拉取数据
        // 后端 mysql -> java 数组 JSON -> incloud templ <%= posts.forEach%>
        const f = fetch('http://localhost:3000/books');
        const f2 = fetch('http://localhost:3000/publisher');
        async function bingFa () {
            try {
                const booksRes = await f;
                const books = await booksRes.json();
                const publisherRes = await f2;
                const publisher = await publisherRes.json();
            } catch(e) {
                
            }
        }
        bingFa();
        //     Promise
        //         .all([f,f2])
        //         .then(response => Promise.all(
        //                 response.map(
        //                     res => res.json()
        //                 )
        //         ))
        //         .then(responses => {
        //             console.log(responses);
        //         })

        //         Promise
        //             .race([f,f2])
        //             .then(response => response.json())
        //             .then(res => {
        //                 console.log(res);
        //             })
        //             .catch(err => {
        //                 console.log(err);
        //             })
    
    </script>
</body>
</html>